﻿using Autofac;
using Sdg.Dal;
using Sdg.Domain;
using Sdg.Domain.Services;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace SDataGen
{
    /// <summary>
    /// Логика взаимодействия для App.xaml
    /// </summary>
    public partial class App : Application
    {
        private static Director _director;
        private IContainer _container;

        public IContainer DIContainer
        {
            get
            {
                return _container;
            }
        }

        public static Director Direcrtor
        {
            get
            {
                return _director;
            }
        }

        public App()
        {
            Startup += App_Startup;
            ContainerBuilder b = new ContainerBuilder();
            b.RegisterModule(new DalModule());
            b.RegisterModule(new AppModule());

            _container = b.Build();
        }

        void App_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {

        }



        void App_Startup(object sender, StartupEventArgs e)
        {
            _director = new Director(_container.Resolve<IViewManager>(new NamedParameter("diContainer", _container), new NamedParameter("mainWindow", MainWindow)));
            _director.InitViews();
        }

        [System.STAThreadAttribute()]
        public static void Main()
        {
            SDataGen.App app = new SDataGen.App();     

            app.Run(new MainWindow());
        }

    }
}
